<?php

/**
 * Event form.
 *
 * @package    IPLIFE
 * @subpackage form
 * @author     alexey.shapran@gmail.com
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class EventForm extends BaseEventForm
{
	public function configure()
	{
 		$this->widgetSchema['title'] = new sfWidgetFormInput(array(),array('style'=>'width:300px'));
		$this->widgetSchema['image'] = new sfWidgetFormInputFileEditable(array(
			'label'     => 'Изображение',
			'file_src'  => sfConfig::get('sf_upload_dir').'/events/'.$this->getObject()->getImage(),
			'is_image'  => true,
			'delete_label' => 'Удалить изображение',
			'edit_mode' => !$this->isNew(),
			'template'  => ($this->getObject()->getImage())	?	'<div><img width="40px" src="/uploads/events/'.$this->getObject()->getImage().'" /><br />%input%<br />%delete% %delete_label%</div>'
															:	'<div>%input%<br />%delete% %delete_label%</div>'
		));

		$this->validatorSchema['image'] = new sfValidatorFile(array( 
			'required'   => false, 
			'path'       => sfConfig::get('sf_upload_dir').'/events', 
			'mime_types' => 'web_images',
			'max_size' => 1000*1024 //1Mb
		));

		//$this->widgetSchema['is_allowed_comments'] = new sfWidgetFormInputCheckbox();
		
		$this->widgetSchema['body'] = new sfWidgetFormTextareaTinyMCE(array(
			'width'  => 850,
			'height' => 350,
		));

		// Setup validators
		$this->validatorSchema['title'] = new sfValidatorString(array('required'=>true));
		$this->validatorSchema['image_delete'] = new sfValidatorBoolean();
	}
}
